package com.luty.test;

import org.I0Itec.zkclient.ZkClient;
import org.apache.zookeeper.CreateMode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.Serializable;

/**
 * Created by liuyunxin on 2017/7/1.
 */
public class ZookeeperTester {

    Logger LOGGER = LoggerFactory.getLogger(ZookeeperTester.class);

    public static void main(String[] args){

        String ZKServers = "0.0.0.0:2181,0.0.0.0:2182,0.0.0.0:2183";
        ZkClient zkClient = new ZkClient(ZKServers);

        User user = new User("1","Luty");

        String path =  zkClient.create("/testuser",user, CreateMode.PERSISTENT);

        System.out.println("Path:"+path);

    }
}

class User implements Serializable {
    String id;
    String name;

    public User(String id, String name){
        setId(id);
        setId(name);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
